package com.acwing.partition18;

import java.io.*;
import java.util.Map;
import java.util.TreeMap;

/**
 * @author `RKC`
 * @date 2022/2/8 17:34
 */
public class AC1715桶列表_离散化 {

    private static Map<Integer, Integer> map = new TreeMap<>();
    private static int n = 0;

    private static final BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    private static final BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(System.out));

    public static void main(String[] args) throws IOException {
        n = Integer.parseInt(reader.readLine());
        for (int i = 0; i < n; i++) {
            String[] ss = reader.readLine().split(" ");
            int a = Integer.parseInt(ss[0]), b = Integer.parseInt(ss[1]), c = Integer.parseInt(ss[2]);
            map.put(a - 1, map.getOrDefault(a - 1, 0) + c);
            map.put(b, map.getOrDefault(b, 0) - c);
        }
        int ans = 0, sum = 0;
        for (Map.Entry<Integer, Integer> entry : map.entrySet()) {
            sum += entry.getValue();
            ans = Math.max(ans, sum);
        }
        writer.write(ans + "\n");
        writer.flush();
    }
}
